import request from '@/utils/request'

export type DictTypeVO = {
  id: number | undefined
  name: string
  type: string
  status: number
  remark: string
  createTime: Date
}

// 查询字典（精简)列表
export const getSimpleDictTypeList = () => {
  return request({
    url: '/system/dict-type/list-all-simple',
    method: 'GET',
  })
}

// 查询字典列表
export const getDictTypePage = (params: any) => {
  return request({
    url: '/system/dict-type/page',
    method: 'GET',
    params,
  })
}

// 查询字典详情
export const getDictType = (id: number) => {
  return request({
    url: `/system/dict-type/get?id=${id}`,
    method: 'GET',
  })
}

export const typeSaveOrUpdate = (data: DictTypeVO) => {
  if (data.id !== null && data.id) {
    return request({
      url: '/system/dict-type/update',
      method: 'PUT',
      data,
    })
  } else {
    return request({
      url: '/system/dict-type/create',
      method: 'POST',
      data,
    })
  }
}
// 新增字典
export const createDictType = (data: DictTypeVO) => {
  return request({
    url: '/system/dict-type/create',
    method: 'POST',
    data,
  })
}

// 修改字典
export const updateDictType = (data: DictTypeVO) => {
  return request({
    url: '/system/dict-type/update',
    method: 'PUT',
    data,
  })
}

// 删除字典
export const deleteDictType = (id: number) => {
  return request({
    url: `/system/dict-type/delete?id=${id}`,
    method: 'DELETE',
  })
}
// 导出字典类型
export const exportDictType = (params) => {
  return request({
    url: '/system/dict-type/export',
    method: 'GET',
    responseType: 'blob',
    params,
  })
}
